package com.company;
import com.aspose.cad.InterpolationMode;
import com.aspose.cad.SmoothingMode;
import com.aspose.cad.TextRenderingHint;
import com.aspose.cad.imageoptions.CadRasterizationOptions;
import com.aspose.cad.imageoptions.SvgOptions;

import java.io.File;

public class Main {

    public static void main(String[] args) {
        System.out.println(args[0]);
        File file = new File(args[0]);
//        String fileName = file.getName().substring(0,file.getName().lastIndexOf("."));
        String filePath = file.getPath();
        //加载PDF
//        String absParsingFile = "D:/dfx/暖气位置建议图.dwg";
//        String absParsingFile = "/Users/zuichudemuyang/Documents/1.dxf";
        com.aspose.cad.Image cadImage = com.aspose.cad.Image.load(args[0]);
        CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions();
//        rasterizationOptions.setPageWidth(1600);
//        rasterizationOptions.setPageHeight(1600);
        rasterizationOptions.setAutomaticLayoutsScaling(true);
        rasterizationOptions.setNoScaling (false);
        rasterizationOptions.setContentAsBitmap(true);
        rasterizationOptions.setLayouts(new String[] {"Model"});
        rasterizationOptions.setDrawType(1);

        SvgOptions svgOptions = new SvgOptions();
        svgOptions.setVectorRasterizationOptions(rasterizationOptions);

        // Set Graphics options
        rasterizationOptions.getGraphicsOptions().setSmoothingMode(SmoothingMode.HighQuality);
        rasterizationOptions.getGraphicsOptions().setTextRenderingHint(TextRenderingHint.AntiAliasGridFit);
        rasterizationOptions.getGraphicsOptions().setInterpolationMode(InterpolationMode.HighQualityBicubic);
        //获取保存路径
//        String[] splitPath  = filePath.split("/");
//        List<String> list = new ArrayList<>(Arrays.asList(splitPath));
//        String filename = file.getName();
//        list.remove(filename);

        // Export to PDF by calling the Save method
//        cadImage.save("/Users/zuichudemuyang/Documents/1.svg", svgOptions);
        cadImage.save(args[1], svgOptions);
    }

}
